varying vec4 gvProjPos;

void main (void)  
{
	mat4 mProjInv = inverse(gl_ProjectionMatrix);
	mat4 mViewInv = inverse(gl_ModelViewMatrix);
	vec4 vViewPos = mProjInv * gvProjPos;
	vec4 vWorldDir = mViewInv * vec4(vViewPos.xyz, 0.0);

	float fShift = (vWorldDir.y + 1.0f) * 0.5f;

	if(fShift < 0.25f)
	{
		gl_FragColor = vec4(0.35f * 0.7f, 0.35f * 0.7f, 0.7, 1.0);
	}
	else if(fShift < 0.5f)
	{
		fShift -= 0.25f;
		fShift *= 4.0f;
		vec3 Color = lerp(vec3(0.35f * 0.7f, 0.35f * 0.7f, 0.7f), vec3(0.35f, 0.35f, 1.0f), fShift);
		gl_FragColor = vec4(Color, 1.0);
	}
	else if(fShift < 0.8f)
	{
		fShift -= 0.5f;
		fShift *= 3.33333f;
		vec3 Color = lerp(vec3(0.35f, 0.35f, 1.0f), vec3(1.0f, 1.0f, 1.0f), fShift);
		gl_FragColor = vec4(Color, 1.0);
	}
	else
	{
		gl_FragColor = vec4(1,1,1, 1.0);
	}
}    
